public class TestDemo {

    public static void main(String[] args) {
        int[] arr1 = {1,2,3,4,5,6,7,8,9,10};
        //
        int[] arr2 = new int[]{1,2,3,4,5,6,7,8,9,10};
        // 1是2的简写,[]里面不能放数字
        int[] arr3 = new int[10];
        // 没有初始化，默认为0
        arr3 = new int[]{1,2,3,4,5,6,7,8,9,10};

        int[] array;
        array = new int[]{1,2,3,4};

        System.out.println(array[10]); // 数组越界

    }

    public static int add(int a, int b) {
        return a+b;
    }

    public static int add(int a, int b, int c) {
        return a+b;
    }

    public static double add(double a, int b) {
        return a+b;
    }

    public static void main3(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(add(a, b));
        System.out.println(add(2.4, 5));
    }

    public static void swap(int x, int y) {
        int tmp = x;
        x = y;
        y = tmp;
        System.out.println("swap: x = " + x + " y = " + y);
    }

//    public static int add(int x, int y) {
//        return x + y;
//    }

    public static void main2(String[] args) {
        int a = 10;
        int b = 20;
        int sum = add(23,58);
        int ret = add(a, b);
    }

    public static void print(int[] arr, int n) {

        if (n == 1) {
            System.out.println(arr[n-1]);
            return;
        }
        print(arr, n-1);
        System.out.println(arr[n-1]);
    }

    public static void main1(String[] args) {
        int[] arr = {1,2,3,4,5};
        print(arr,arr.length);
    }

}
